<?php
include(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'bootstrap.php');

$view = new View();

if (isset($_POST['login']) &&
    isset($_POST['password'])) {

    $user_table = new UserTable();
    try {
        $user = $user_table->authenticate($_POST['login'], $_POST['password']);
        $_SESSION['login']     = $user->login;
        $_SESSION['full_name'] = $user->full_name;
    } catch (AuthenticationException $e) {
        $view->redirect('index.php?login_fail');
        die;
    }
}

$view->redirect('index.php');
